
class TrackStats {
  int instrument;
  PVector notesRange;
  PVector velocityRange;
  PVector durationRange;

  ArrayList<Float> notes;  
  ArrayList<Float> velocityes;
  ArrayList<Float> durations;  

  TrackStats(int instrument) {
    this.instrument = instrument;
    notesRange = new PVector(0, 128);
    velocityRange = new PVector(0, 127);
    durationRange = new PVector(1, 8);
    notes = new ArrayList<Float>();
    velocityes = new ArrayList<Float>();
    durations = new ArrayList<Float>();
  }

  float getNotesSD() {
    float summ = 0;
    for (float val:notes) {
      summ += val;
    }
    float avg = summ/notes.size();
    float summ2 = 0;
    for (float val:notes) {
      summ2 += pow((val-avg), 2);
    }
    return sqrt(summ2/notes.size());
  }

  float getDurationsSD() {
    float summ = 0;
    for (float val:durations) {
      summ += val;
    }
    float avg = summ/durations.size();
    float summ2 = 0;
    for (float val:durations) {
      summ2 += pow((val-avg), 2);
    }
    return sqrt(summ2/durations.size());
  }

  float getVelocityesSD() {
    float summ = 0;
    for (float val:velocityes) {
      summ += val;
    }
    float avg = summ/velocityes.size();
    float summ2 = 0;
    for (float val:velocityes) {
      summ2 += pow((val-avg), 2);
    }
    return sqrt(summ2/velocityes.size());
  }

  void addParameter(float val, ArrayList<Float> parameters) {
    parameters.add(val);
  }
}

float avg(ArrayList<Float> params){
  float summ = 0;
  for (int i = 0; i < params.size(); i++){
    summ += params.get(i);
  }
  return round(summ/params.size());
}

float avgDur(ArrayList<Float> params){
  float summ = 0;
  for (int i = 0; i < params.size(); i++){
    summ += getDurationNum(params.get(i));
  }
  return round(summ/params.size());
}

